package ninegag.storm.me.testloginmvp.model;

import android.util.Log;
import android.util.SparseArray;

/**
 * Action:处理数据的逻辑,保存数据和获取数据,都在这里处理
 * Created by zxy on 2017/7/20.
 * ninegag.storm.me.testloginmvp.model.
 */

public class UserModel implements IUserModel {
    private SparseArray<UserBean> mSparseArray = new SparseArray<>();

    @Override
    public void userSaveInfo(int userId, String userName, String userPassword) {
        mSparseArray.append(userId, new UserBean(userName, userPassword));
        Log.d("UserModel", "mSparseArray.size():" + mSparseArray.size());
    }

    @Override
    public UserBean getUserInfo(int userId) {
        if (mSparseArray.indexOfKey(userId) >= 0) {
            return mSparseArray.get(userId);
        } else {
            return null;
        }
    }
}
